package com.web.forum.web;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.web.forum.ao.ForumAo;

@Controller
@RequestMapping("/forum")
public class ForumAction
{
	@Autowired
	private ForumAo forumAo;
	
	@RequestMapping("/new")
	public ModelAndView news(HttpServletRequest request,HttpServletResponse response,String name,String label)
	{
		String str = forumAo.news (request ,name ,label);
		try
		{
			if(str.equals ("�Ѿ�������ͬ�����Ƶ�����,����ʧ��!"))
			{
				response.sendRedirect ("/forum/create_success.shtml?message=no");
			}else
			{
				response.sendRedirect ("/forum/create_success.shtml?message=yes");
			}
			
		}catch (IOException e)
		{
			e.printStackTrace();
		}
		
		return null;
	}
	
	
	/**
	 * ������̳
	 * @param request
	 * @param forumId
	 * @return
	 */
	@RequestMapping("/join")
	public ModelAndView join(HttpServletRequest request,long forumId)
	{
		forumAo.join (request ,forumId);
		return null;
	}
}
